using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;

namespace PrismDemo.ViewModels
{
    public class WelcomeViewModel : BindableBase
    {
        private readonly IRegionManager _regionManager;
        private readonly IDialogService _dialogService;

        public WelcomeViewModel(IRegionManager regionManager, IDialogService dialogService)
        {
            _regionManager = regionManager;
            _dialogService = dialogService;

            // 初始化Commands
            NavigateToUsersCommand = new DelegateCommand(NavigateToUsers);
            NavigateToProductsCommand = new DelegateCommand(NavigateToProducts);
            ShowDialogDemoCommand = new DelegateCommand(ShowDialogDemo);
        }

        #region Commands

        public DelegateCommand NavigateToUsersCommand { get; }
        public DelegateCommand NavigateToProductsCommand { get; }
        public DelegateCommand ShowDialogDemoCommand { get; }

        #endregion

        #region Command Methods

        private void NavigateToUsers()
        {
            _regionManager.RequestNavigate("ContentRegion", "UserListView");
        }

        private void NavigateToProducts()
        {
            _regionManager.RequestNavigate("ContentRegion", "ProductListView");
        }

        private void ShowDialogDemo()
        {
            var parameters = new DialogParameters
            {
                { "title", "演示对话框" },
                { "message", "这是一个演示对话框，展示PRISM Dialog服务的使用方法。\\n\\n您可以在用户管理和产品管理模块中看到更多对话框的实际应用。" }
            };

            _dialogService.ShowDialog("NotificationDialog", parameters, result =>
            {
                // 对话框关闭后可以执行其他操作
            });
        }

        #endregion
    }
}